<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>审批</title>
<link rel="stylesheet" type="text/css"
	href=${pageContext.servletContext.contextPath}/themes/default/easyui.css>
<link rel="stylesheet" type="text/css"
	href=${pageContext.servletContext.contextPath}/themes/icon.css>
<link rel="stylesheet" type="text/css"
	href=${pageContext.servletContext.contextPath}/themes/bootstrap/easyui.css>
<link rel="stylesheet" 
	href=${pageContext.servletContext.contextPath}/js/bootstrap.min.css>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/js/jquery.min.js></script>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/js/bootstrap.min.js></script>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/js/jquery.easyui.min.js></script>
<script type="text/javascript"
	src=${pageContext.servletContext.contextPath}/js/easyui-lang-zh_CN.js></script>
</head>
<script type="text/javascript">
$(function(){
	$('#msg').dialog('close');
	var id = 0;
	//加载页面
	$('#dg').datagrid({
		url : '${pageContext.servletContext.contextPath}/loadDeskH',
		striped : true,
		pageSize : 10,
		pageList : [ 5, 10, 15, 20],
		pagination : true,
		loadMsg : '正在加载',
		columns : [ [ 
		   {field : 'cb',checkbox : true,width : 100,align : 'center',halign : 'center'
		}, {field : 'oid',title : '菜单号',width : 200,align : 'center',halign : 'center'
		}, {field : 'did',title : '桌号',width : 200,align : 'center',halign : 'center'
		}, {field : 'state',title : '审批状态',width : 200,align : 'center',halign : 'center'
		}, {field : 'ftime',title : '提交菜单时间',width : 200,align : 'center',halign : 'center'
		} ] ],
		toolbar : [{
			text : '查看菜单详情',
			iconCls : 'icon-search',
			width : 200,
			align : 'center',
			halign : 'center',
			handler : function() {
				var cks = $('#dg').datagrid('getSelections');
				if (cks.length == 1) {
					$.each(cks, function(i, n) {
						id = n.oid;
					})
					$.ajax({
						url:"${pageContext.servletContext.contextPath}/checkDeskH",
						dataType : "json",
						async : true,
						data : {
							"oid" : id
						},
						type : "post",
						success : function(r) {
							$("#oid").text(r.oid);
							$("#did").text(r.did);
							$("#foodname").text(r.foodname);
							$("#wname").text(r.wname);
							$("#state").text(r.state);
							$("#fnum").text(r.fnum);
							$("#ftime").text(r.ftime);
							$("#fprice").text(r.fprice);
						}
					})	
					$('#msg').dialog('open');
				} else {
					$.messager.alert('提示','请选择一行查看！', 'info');
				}
			}
		},'-',{
			text : '刷新菜单',
			iconCls : 'icon-reload',
			width : 200,
			align : 'center',
			halign : 'center',
			handler : function() {
				$('#dg').datagrid('reload');
			}
		}]
	});
	//通过审批
	$("#tg").click(function(){
		$('#msg').dialog('close');
		$("#oid").text("");
		$("#did").text("");
		$("#foodname").text("");
		$("#wname").text("");
		$("#state").text("");
		$("#fnum").text("");
		$("#ftime").text("");
		$("#fprice").text("");
		$.ajax({
			url : "${pageContext.servletContext.contextPath}/changeDeskH",
			dataType : "json",
			async : true,
			type : "post",
			data : {
				"fstate" : 1
			},
			success : function(r) {
				if (r.flag != 0) {
					$('#dg').datagrid('reload');
					$.messager.alert('提示', '操作成功！', 'info');
				} else {
					$.messager.alert('提示', '操作失败！', 'info');
				}
			}
		});	
	});
	
	//不通过审批
	$("#btg").click(function(){
		$('#msg').dialog('close');
		$("#oid").text("");
		$("#did").text("");
		$("#foodname").text("");
		$("#wname").text("");
		$("#state").text("");
		$("#fnum").text("");
		$("#ftime").text("");
		$("#fprice").text("");
		$.ajax({
			url : "${pageContext.servletContext.contextPath}/changeDeskH",
			dataType : "json",
			async : true,
			type : "post",
			data : {
				"fstate" : 0
			},
			success : function(r) {
				if (r.flag != 0) {
					$('#dg').datagrid('reload');
					$.messager.alert('提示', '操作成功！', 'info');
				} else {
					$.messager.alert('提示', '操作失败！', 'info');
				}
			}
		});	
	});
});
</script>
<body>
<table id="dg"></table>
<div id="msg" class="easyui-dialog" title="菜单详情" style="width:600px;height:350px;"   
        data-options="iconCls:'icon-save',resizable:true,modal:true"> 
	<h4><span class="label label-default">菜单号：</span><span id="oid"></span></h4>
	<h4><span class="label label-default">桌号：</span><span id="did"></span></h4>
	<h4><span class="label label-default">菜名：</span><span id="foodname"></span></h4>
	<h4><span class="label label-default">点菜员：</span><span id="wname"></span></h4>
	<h4><span class="label label-default">审批状态：</span><span id="state"></span></h4>
	<h4><span class="label label-default">人数：</span><span id="fnum"></span></h4>
	<h4><span class="label label-default">提交时间：</span><span id="ftime"></span></h4>
	<h4><span class="label label-default">价格：</span><span id="fprice"></span></h4>
	<div>
	<a id="tg" class="easyui-linkbutton btn btn-primary" data-options="iconCls:'icon-ok',plain:true"
		style="width: 50%; height: 32px">通过审批！</a>
	<a id="btg" class="easyui-linkbutton btn btn-primary" data-options="iconCls:'icon-no',plain:true"
		style="width: 49%; height: 32px">不通过审批！</a>
</div>
</div>
</body>
</html>